require("sys")
local dsec = {}
local heartCount=1
-- 心跳
local function Heart()
    log.info("---------PubHeart---------")
    sys.publish("ddn_event", {src = "dsec",evt = "HEART",dat={heart=heartCount}})    
    heartCount=heartCount+1    
end
local function Second()
    log.info("---------PubSecond---------")
    local t1 = rtc.get()
    local t2 = string.format("%04d-%02d-%02d %02d:%02d:%02d", t1.year, t1.mon, t1.day, t1.hour, t1.min,t1.sec)
    sys.publish("ddn_event", {src = "dsec",evt = "SECOND", dat = {time = t2}})
end

local function SecMain()
    while true do
        sys.wait(5000)
        Heart()
    end    
end

local function Init()
    log.info("-------dsec init----------")
    sys.taskInit(SecMain)
end
dsec.Init = Init
return dsec
